<?php

class userController extends Controller{

    public function userdata(){
        $page = isset($_GET['page']) ? $_GET['page'] : 1;
        $userModel = new userModel();
        $userDtas = $userModel->selectUser($page);
        $this->assign('users',$userDtas['user']);
        $this->assign('paging',$userDtas['page']);
        $this->assign('pagesize',$userDtas['allPage']);
        $this->assign('page',$page);
        // var_dump($user);
        $this->display('user.tpl');
        
    }


    public function uback($pages){
        $page = isset($_GET['page']) ? $_GET['page'] : 1;
        $userModel = new userModel();
        $userDtas = $userModel->selectUser($page);
        $this->assign('users',$userDtas['user']);
        $this->assign('paging',$userDtas['page']);
        $this->assign('pagesize',$userDtas['allPage']);
        $this->assign('page',$page);
        // var_dump($user);
        $this->display('user.tpl');
        
    }

    public function usersearch(){
        $userModel = new userModel();
        $text = isset($_GET['text']) ? $_GET['text'] : '';
        $page = isset($_GET['page']) ? $_GET['page'] : 1;
        $userDtas = $userModel->search($text,$page);
        $this->assign('users',$userDtas['user']);
        $this->assign('paging',$userDtas['page']);
        $this->assign('pagesize',$userDtas['allPage']);
        $this->assign('page',$page);
        $this->display("user.tpl");

    }

    public function userdel(){
        $uid = isset($_GET['uid']) ? $_GET['uid'] : 0;
        $page = isset($_GET['page']) ? $_GET['page'] : 0;
        $model = new userModel();
        $ttr = $model->udel($uid);
        if($ttr){
            $this->uback($page);
        }else{

        }
    }
}